using UnityEngine;
using System.Collections;

public class PlayerMirror : MonoBehaviour 
{
    public Transform look;
    public Transform player;
    public float newX;
    public float newY;
    public float newZ;
    public Vector3 newAngle; 
	void Update () 
    {
        look.transform.LookAt(player.position);
        RaycastHit hit;
        if (Physics.Raycast(look.position, look.forward, out hit))
        {
            if (hit.collider.gameObject.transform == player)
            {
                renderer.enabled = true;
                collider.enabled = true;
            }
            else
            {
                renderer.enabled = false;
                collider.enabled = false;
            }
        }
        newX = player.position.x;
        newY = player.position.y;
        newZ = player.position.z * -1;
        newAngle = new Vector3(0, (player.localEulerAngles.y + 180)* -1, 0);
        transform.eulerAngles = newAngle;
        transform.position = new Vector3(newX, newY, newZ);
	}
}
